from django.conf import settings
from django.contrib import admin
from django.urls import path, re_path, include
from django.views.generic import RedirectView
from django.views.static import serve

import Hello.views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('index/', Hello.views.index, name="index"),
    # 配置博客路由变量
    path('blog/<int:id>/<int:year>/<int:month>/<int:day>', Hello.views.blog),

    # 正则路由
    re_path('blogs/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})', Hello.views.blogs),

    # 路由重定向
    path('redirectTo', RedirectView.as_view(url="index/")),
    # 配置媒体文件的路由地址
    re_path('media/(?P<path>.*)', serve, {'document_root': settings.MEDIA_ROOT}, name='media'),

    # 命名空间namespace
    path('user/', include(('user.urls', 'user'), namespace='user')),
    path('order/', include(('order.urls', 'order'), namespace='order')),

    # 下载文件
    path('download1', Hello.views.download_file1),
    path('download2', Hello.views.download_file2),
    path('download3', Hello.views.download_file3),

    # get和post请求
    path('get/', Hello.views.get_test),
    path('post/', Hello.views.post_test),

    # cookie登录
    path('toLogin/', Hello.views.to_login),
    path('login/', Hello.views.login),

    # 文件上传
    path('toUpload/', Hello.views.to_upload),
    path('upload', Hello.views.upload),

    # ListView列表视图
    path('student/list', Hello.views.List.as_view()),

    # DetailView详细信息视图
    path('student/<int:pk>', Hello.views.Detail.as_view()),

    # CreateView新增信息视图
    path('student/create', Hello.views.Create.as_view()),

    # UpdateView修改信息视图
    path('student/update/<int:pk>', Hello.views.Update.as_view()),

    # DeleteView删除信息视图
    path('student/delete/<int:pk>', Hello.views.Delete.as_view()),

    # 模板继承
    path('toCourse/',Hello.views.to_course),

    # jinja3
    path('jinja/', Hello.views.jinja),

]






















